package cn.sytton.taffe.web.sys.entity;

import cn.sytton.taffe.framework.base.entity.BaseUpdatedEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;

/**
 * 部门entity sys_dept
 *
 * @author skyrock
 */
@Schema(description = "部门")
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("sys_dept")
public class DeptEntity extends BaseUpdatedEntity {

    @Schema(description = "部门ID(主键)")
    @TableId(type = IdType.ASSIGN_ID)
    private String deptId;    // 部门ID 

    @Schema(description = "部门名称")
    @NotNull(message = "部门名称不能为空")
    private String deptName;    // 部门名称 

    @Schema(description = "部门编号")
    private String deptCode;    // 部门编号

    @Schema(description = "电话")
    private String telephone; //电话

    @Schema(description = "顺序")
    private Integer seq =  0;    // 顺序 

    @Schema(description = "上级部门ID")
    private String parentId;    // 上级部门ID 

    @Schema(description = "状态（1启用 0禁用）")
    private Integer status =  1;    // 状态（1启用 0禁用）

    //-----以下是关联属性-----

    @Schema(description = "下级部门列表", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(exist = false)
    private List<DeptEntity> children = new ArrayList<>();

    @Schema(description = "部门成员数量", accessMode = Schema.AccessMode.READ_ONLY)
    @TableField(exist = false)
    private Integer userCount = 0; //用户数量
}
